package iammry.com.activity;
import android.content.DialogInterface;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import com.lidroid.xutils.view.annotation.ViewInject;
import iammry.com.R;
import iammry.com.base.BaseActivity;
import iammry.com.popuwindow.MyCustomDialog;
import iammry.com.popuwindow.MyCustomDialog.Builder;


public class SetActivity extends BaseActivity implements OnClickListener{

	@ViewInject(R.id.ll_close)
	LinearLayout ll_close;

	@ViewInject(R.id.ll_personinfo)
	LinearLayout ll_personinfo;

	@ViewInject(R.id.ll_exit)
	LinearLayout ll_exit;

	@ViewInject(R.id.ll_bind)
	LinearLayout ll_bind;

	private MyCustomDialog dialog;


	@Override
	protected void initView() 
	{
		setLayout(this, R.layout.set_layout);
	}


	@Override
	protected void initData()
	{
		ll_close.setOnClickListener(this);
		ll_personinfo.setOnClickListener(this);
		ll_exit.setOnClickListener(this);
		ll_bind.setOnClickListener(this);
	}

	@Override
	protected void initEvent() 
	{
		
	}


	@Override
	public void onClick(View view) 
	{

		switch (view.getId()) {
		
		case R.id.ll_close:
			
			finish();
			
			break;
			
		case R.id.ll_personinfo:
			
			startActivity(PersonInfoActivity.class);
			
			break;
			
		case R.id.ll_exit:
			
			showAlertDialog(1);
			
			break;
			
		case R.id.ll_bind:
			
			showAlertDialog(2);
				
			break;

		default:
			break;
		}
	}
	
	// 弹窗
		public void showAlertDialog(final int type) {

			Builder builder = new MyCustomDialog.Builder(context);
			// builder.setTitle("提示");
			builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
				public void onClick(DialogInterface dialog, int which) {

					dialog.dismiss();
					if(type==1)
					{
						
					}
					else if(type==2)
					{

						//解绑牙刷成功后跳转
						startActivity(ScanBlueActivity.class);
                        finish();
					}
				}
			});
			if (type == 1) {
				builder.setMessage("确定要退出吗?");
			} else if (type == 2) {
				builder.setMessage("是否需要解绑牙刷?");

			}

			builder.setNegativeButton("取消",
					new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog, int which) {

							/* ProgressDialogFactory.dismissProgress(); */
							dialog.dismiss();
						}
					});
			builder.create().getWindow().setGravity(Gravity.FILL);

			builder.create().show();

		}

}
